#pragma once

#include "Perceptron.h"

#include <vector>

using std::vector;

class Root
{
private:
	Perceptron *_pPerceptron;
	vector<double> _dataTrain;
	unsigned int _power;
	unsigned int _lastNumPeriods;
	double _lastLearningTime;

	static double RandomValue(double from, double to);
	void GeneratePlot(const char* fileName, double from, double to, unsigned int numSteps);

public:
	Root();
	~Root();

	void SetTrainData(vector<double> &data);

	void Learn(
		unsigned int power, 
		double learnFactor, 
		double momentum, 
		unsigned int periodsLimit,
		unsigned int numHiddenNeurons,
		double timeLimit = -1.0);

	double Count(double x);
	double CountError();
	inline double GetNumPeriods() { return _lastNumPeriods; }
	inline double GetLearningTime() { return _lastLearningTime; }

	static vector<double> GenerateTrainData(unsigned int power, unsigned int number);
};
